/*
 * maz_mod_ili9225g.h
 *
 *  Created on: 2020年2月18日
 *      Author: Paul
 */

#ifndef MAZ_MOD_ILI9225G_H_
#define MAZ_MOD_ILI9225G_H_

#include "maz_com.h"
#include "maz_drv.h"
#include "maz_mod.h"
#include <maz_mod_fonts.h>
#include <maz_mod_colors.h>

typedef enum _MAZMOD_ILI9225G_
{
    MAZMOD_ILI9225G_MIN = 0,
    MAZMOD_ILI9225G0 = 0,
    MAZMOD_ILI9225G_MAX,
} MAZMOD_ILI9225G;

#define delay_ms(t)         HAL_Delay(t)
#define delay_s(t)          delay_ms(1000 * t)

#define MAZRET_NOERR        0

#define LCD_X_SIZE          176
#define LCD_Y_SIZE          220

//支持横竖屏快速定义切换
#define USE_HORIZONTAL          0   //定义是否使用横屏      0,不使用.1,使用.

#ifdef USE_HORIZONTAL//如果定义了横屏
#define X_MAX_PIXEL         LCD_Y_SIZE
#define Y_MAX_PIXEL         LCD_X_SIZE
#else
#define X_MAX_PIXEL         LCD_X_SIZE
#define Y_MAX_PIXEL         LCD_Y_SIZE
#endif

#define  CS_H       GPIOA->BSRR = GPIO_PIN_4;
#define  CS_L       GPIOA->BSRR = GPIO_PIN_4 << 16;

#define  DC_H       GPIOA->BSRR = GPIO_PIN_5;
#define  DC_L       GPIOA->BSRR = GPIO_PIN_5 << 16;

#define  WR_H       GPIOA->BSRR = GPIO_PIN_6;
#define  WR_L       GPIOA->BSRR = GPIO_PIN_6 << 16;

#define  RD_H       GPIOA->BSRR = GPIO_PIN_7;
#define  RD_L       GPIOA->BSRR = GPIO_PIN_7 << 16;

#define  RES_H      GPIOA->BSRR = GPIO_PIN_8;
#define  RES_L      GPIOA->BSRR = GPIO_PIN_8 << 16;

#define  BL_ON      GPIOA->BSRR = GPIO_PIN_11;
#define  BL_OFF     GPIOA->BSRR = GPIO_PIN_11 << 16;

#define GPIO_WriteLow(GPIOx, val)    GPIOx->ODR = val;

int MAZ_Mod_ili9225g_select(void);
int MAZ_Mod_ili9225g_unselect(void);

void MAZ_Mod_ili9225g_gpio_config(void);
void MAZ_Mod_ili9225g_init(void);
int MAZ_Mod_ili9225g_clear_screen(uint16_t Color);
int MAZ_Mod_ili9225g_set_region(MAZMOD_ILI9225G index, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end);
int MAZ_Mod_ili9225g_set_position(uint16_t x, uint16_t y);
int MAZ_Mod_ili9225g_draw_pixel(MAZMOD_ILI9225G index, uint16_t x, uint16_t y, uint16_t color);
int MAZ_Mod_ili9225g_draw_char(MAZMOD_ILI9225G index, uint16_t x, uint16_t y, char ch, FontDef font, uint16_t color, uint16_t bgcolor);
int MAZ_Mod_ili9225g_draw_string(MAZMOD_ILI9225G index, uint16_t x, uint16_t y, const char *str, FontDef font, uint16_t color, uint16_t bgcolor);
int MAZ_Mod_ili9225g_show_image(const unsigned char *p);



#endif /* MAZ_MOD_ILI9225G_H_ */
